package com.octopus.kernal.util.xml;

import java.lang.reflect.InvocationTargetException;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.apache.commons.beanutils.BeanUtils;

@XmlType(name="Field", propOrder = {"name", "column", "elementDetail", "elementSearch"})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Field {
	
	@XmlAttribute
	private String name;
	
	@XmlAttribute
	private Boolean required = false;
	
	@XmlElement(name="Column")
	private Column column;
	
	@XmlElement(name="ElementDetail")
	private ElementDetail elementDetail;
	
	@XmlElement(name="ElementSearch")
	private ElementSearch elementSearch;
	
	public Field clone(){
		Field result = new Field();
		try {
			BeanUtils.copyProperties(result, this);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		}
		return result;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Column getColumn() {
		return column;
	}

	public void setColumn(Column column) {
		this.column = column;
	}

	public ElementDetail getElementDetail() {
		return elementDetail;
	}

	public void setElementDetail(ElementDetail element) {
		this.elementDetail = element;
	}

	public Boolean getRequired() {
		return required;
	}

	public void setRequired(Boolean required) {
		this.required = required;
	}

	public ElementSearch getElementSearch() {
		return elementSearch;
	}

	public void setElementSearch(ElementSearch elementSearch) {
		this.elementSearch = elementSearch;
	}

}
